(function() {
    angular.module('BlurAdmin.pages.shops')
        .controller('addShopCtrl', addShopCtrl);

    function addShopCtrl($scope, $ShareData, $datepicker, $qupload, $http, $mydialog, $log, $filter, $myconfig) {

        $scope.saveShop = function () {
            if(!$scope.shop.name){
                return $mydialog.fail('请输入店铺名称');
            }

            var url = $scope.is_update ? $myconfig.api.UPDATE_SHOP : $myconfig.api.ADD_SHOP;
            $http.post(url, $scope.shop).then(function (res) {
                if (res.data.success) {
                    $scope.search_data(); //刷新通知列表，父级定义方法；
                    $scope.opt_close(); //关闭弹出窗口
                    return $mydialog.success($scope.is_update ? "修改成功": "添加成功");
                } else {
                    return $mydialog.fail(res.data.data);
                }
            });
        };

    }
})();